package com.example.back.controller;

import com.example.back.dto.req.GetEscortReserveList;
import com.example.back.dto.req.ProcessEscortReserve;
import com.example.back.dto.req.RemoveEscortReserve;
import com.example.back.dto.resp.EscortReserveList;
import com.example.back.dto.resp.EscortReserveVo;
import com.example.back.service.EscortReserveService;
import com.example.common.support.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;


/**
 * @ClassName EscortReserveController
 * @Author wengjt
 * @Date 2021/5/7 13:14
 * @Description
 **/
@RestController
@RequestMapping("/escortReserve")
@Api(tags = "陪护订单管理")
public class EscortReserveController {
    @Resource
    private EscortReserveService escortReserveService;

    @GetMapping("/escortReserveList")
    @ApiOperation(value = "多条件查询陪护订单", notes = "多条件查询陪护订单")
    public Result<EscortReserveList> getEscortReserveList(GetEscortReserveList dto) {
        return Result.success(escortReserveService.getEscortReserveList(dto.getEscortProductName(), dto.getEscortTypeId(), dto.getRStatus(), dto.getPageNum(), dto.getPageSize()));
    }

    @GetMapping("/info")
    @ApiOperation(value = "获取单个陪护订单详情", notes = "单个订单详情")
    @ApiImplicitParam(name = "escortReserveId", value = "陪护订单id")
    public Result<EscortReserveVo> getEscortReserveInfo(String escortReserveId) {
        return Result.success(escortReserveService.getEscortReserveInfo(escortReserveId));
    }

    @DeleteMapping("")
    @ApiOperation(value = "删除订单", notes = "删除订单")
    public Result<Object> removeEscortReserve(@RequestBody RemoveEscortReserve dto) {
        return Result.success(escortReserveService.removeEscortReserve(dto.getEscortReserveId()));
    }

    @PostMapping("/process")
    @ApiOperation(value = "处理订单",notes = "处理订单")
    public Result<Object> processEscortReserve(@RequestBody ProcessEscortReserve dto) {
        return Result.success(escortReserveService.processEscortReserve(dto.getEscortReserveId(), dto.getRStatus(), dto.getCaregiverName(), dto.getCaregiverPhone(), dto.getRemark(), dto.getRefuse()));
    }
}
